Skip to content

feat(api): add invoice V3 GET endpoint - #4541

Merged
tothandras merged 3 commits into
mainfrom
feat/v3-invoice-api-get
Jun 26, 2026
Merged

feat(api): add invoice V3 GET endpoint#4541
tothandras merged 3 commits into
mainfrom
feat/v3-invoice-api-get

Conversation

@borosr

@borosr borosr commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

Overview

Fixes #(issue)

Notes for reviewer

Summary by CodeRabbit

  • New Features
    • Added billing invoice retrieval to the JavaScript SDK, including a new Invoices surface and an invoices.get operation to fetch invoices by ID.
    • Expanded invoice-related models/types across the SDK to support workflow, status/validation details, and invoice/line/discount structures.
    • Introduced a v3 “billing invoices” GET by ID endpoint with new end-to-end test coverage.
  • Bug Fixes
    • Improved v3 invoice conversion behavior and invoice error encoding (including validation and not-found handling).
  • Documentation
    • Updated the JavaScript SDK README to document the new Invoices resource and operation.

@borosr
borosr requested review from rolosp, tothandras and turip June 18, 2026 13:57
@borosr borosr self-assigned this Jun 18, 2026
@borosr borosr added the release-note/feature Release note: Exciting New Features label Jun 18, 2026
@coderabbitai

coderabbitai Bot commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Adds billing invoice GET support across the TypeSpec API, JavaScript SDK, Go v3 handler path, and end-to-end tests.

Changes

Billing invoice GET endpoint

Layer / File(s) Summary
TypeSpec invoice contract
api/spec/packages/aip/src/invoices/*, api/spec/packages/aip/src/openmeter.tsp, api/spec/packages/aip/src/konnect.tsp
Defines the invoice union, standard and credit-note invoice shapes, line-item and workflow models, and the GET operation and route exposure.
JavaScript models and schemas
api/spec/packages/aip-client-javascript/src/models/*, api/spec/packages/aip-client-javascript/src/index.ts
Adds invoice request/response models, schemas, exported invoice types, and input shapes for the client package.
JavaScript client surface
api/spec/packages/aip-client-javascript/src/funcs/*, api/spec/packages/aip-client-javascript/src/sdk/*, api/spec/packages/aip-client-javascript/README.md
Adds the invoice GET helper, SDK wrapper, lazy client accessor, and package documentation.
Go conversion helpers
api/v3/handlers/billinginvoices/convert.go, api/v3/handlers/billingprofiles/convert.go, api/v3/handlers/customers/charges/convert.go
Maps billing invoices into the v3 API invoice union, including invoice status, workflow, customer, line-item, discount, credit, and reference fields.
Go handler and server wiring
api/v3/handlers/billinginvoices/*, api/v3/server/*
Adds the billing invoices handler, GET endpoint, error encoding, and server route wiring for /openmeter/billing/invoices/{invoiceId}.
End-to-end validation
e2e/billinginvoices_v3_test.go, e2e/v3helpers_test.go
Adds the v3 helper and end-to-end coverage for successful invoice fetches and not-found responses.

Sequence Diagram(s)

sequenceDiagram
  participant Client
  participant Server
  participant billingService
  participant ToAPIBillingInvoice
  Client->>Server: GET /openmeter/billing/invoices/{invoiceId}
  Server->>billingService: GetInvoiceById(...)
  billingService-->>Server: billing.Invoice
  Server->>ToAPIBillingInvoice: convert invoice
  ToAPIBillingInvoice-->>Server: api.BillingInvoice
  Server-->>Client: JSON response
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Suggested labels

area/api, kind/feature

Suggested reviewers

  • tothandras
  • chrisgacsal
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 28.57% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly summarizes the main change: adding a V3 GET endpoint for invoices.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/v3-invoice-api-get

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@borosr borosr changed the title Feat/v3 invoice api get Invoice V3 API Get endpoint Jun 18, 2026
Comment thread api/spec/packages/aip/src/invoices/invoice.tsp Outdated
Comment thread api/spec/packages/aip/src/invoices/invoice.tsp Outdated
Comment thread api/spec/packages/aip/src/invoices/invoice.tsp Outdated
Comment thread api/spec/packages/aip/src/invoices/invoice.tsp Outdated
Comment thread api/spec/packages/aip/src/invoices/invoice.tsp Outdated
Comment thread api/spec/packages/aip/src/invoices/invoice.tsp Outdated
Comment thread api/spec/packages/aip/src/invoices/invoice.tsp Outdated
Comment thread api/spec/packages/aip/src/invoices/invoice.tsp Outdated
Comment thread api/spec/packages/aip/src/invoices/invoice.tsp Outdated
Comment thread api/spec/packages/aip/src/invoices/invoice.tsp Outdated
Comment thread api/spec/packages/aip-client-javascript/src/sdk/invoices.ts Outdated
Comment thread api/spec/packages/aip/src/invoices/invoice.tsp Outdated
Comment thread api/spec/packages/aip/src/invoices/invoice.tsp Outdated
Comment thread api/spec/packages/aip/src/invoices/invoice.tsp Outdated
Comment thread api/spec/packages/aip/src/invoices/invoice.tsp Outdated
Comment thread api/spec/packages/aip/src/invoices/invoice.tsp Outdated
Comment thread api/spec/packages/aip/src/invoices/invoice.tsp Outdated
@borosr
borosr force-pushed the feat/v3-invoice-api-get branch 3 times, most recently from f7ca272 to 3e3c3d5 Compare June 23, 2026 12:46
@borosr
borosr marked this pull request as ready for review June 23, 2026 12:46
@borosr
borosr requested a review from a team as a code owner June 23, 2026 12:46
@greptile-apps

greptile-apps Bot commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR adds a v3 GET /openmeter/billing/invoices/{invoiceId} endpoint backed by a new billinginvoices handler package, wires it into the server and routes, extends the TypeSpec definitions with the full invoice/line/discount model tree, and regenerates the JavaScript SDK to expose an invoices.get() surface. It also renames several charge-related TypeSpec models (BillingFlatFeeChargeBillingChargeFlatFee, etc.) and renames the shared managed_by field to lifecycle_controller in the charges API response.

  • New invoice GET handler (api/v3/handlers/billinginvoices/): converts domain billing.Invoice unions to the v3 API type, with per-line rate card, discount, credit, and detailed-line mapping; gathering and other non-standard invoice types return 404.
  • TypeSpec expansion (api/spec/packages/aip/src/invoices/invoice.tsp): ~940 lines of new model and enum definitions for the invoice, line, discount, and workflow snapshot hierarchy, plus a new InvoicesOperations interface registered in both openmeter.tsp and konnect.tsp.
  • Breaking API change in charges endpoint: the JSON field managed_by is renamed to lifecycle_controller and the subscription enum value is removed (merged into system), which is a wire-level breaking change for any existing v3 clients reading charge responses.

Confidence Score: 3/5

The new invoice GET handler and TypeSpec definitions are structurally sound, but the accompanying rename of the managed_by → lifecycle_controller wire field in the charges response is a breaking change that could silently corrupt data for any existing v3 charges consumer.

The charges handler change renames a JSON response field and removes an enum value at the wire level. Any client that was already reading the v3 charges endpoint and inspecting managed_by or matching on the value subscription will receive empty or wrong data without any error signal. This is compounded by the open issues carried over from earlier review rounds on convert.go (null detailed_lines, invalid status values for deleted invoices, unsupported invoice type masked as 404). The new invoice handler itself is well-structured and the e2e coverage is a positive addition.

api/v3/handlers/customers/charges/convert.go (breaking wire change), api/v3/handlers/billinginvoices/convert.go (carries open issues from prior rounds), api/spec/packages/aip/src/customers/charges/charges.tsp (TypeSpec source of the breaking rename)

Important Files Changed

Filename Overview
api/v3/handlers/billinginvoices/convert.go New conversion layer from billing.Invoice to v3 API types; several open issues from previous review rounds remain (null detailed_lines, delete-status invalid enum, unsupported-type masked as 404); mapRateCard and FromBillingInvoiceStandardLine errors are now properly propagated.
api/v3/handlers/billinginvoices/get.go Clean handler wiring; always fetches with InvoiceExpandAll which is correct for single-resource GET per the TypeSpec contract.
api/v3/handlers/billinginvoices/error_encoder.go Standard error-encoder chain covering NotFound, ValidationError, UpdateAfterDelete, ValidationIssue, and AppError; consistent with other handlers in the server.
api/v3/handlers/customers/charges/convert.go Renames managed_by → lifecycle_controller (wire field change) and removes the subscription enum value (merged into system), constituting a breaking wire change for existing v3 clients. Type renames (BillingFlatFeeCharge → BillingChargeFlatFee, etc.) also flow through here.
api/spec/packages/aip/src/invoices/invoice.tsp Large new TypeSpec file defining the full invoice/line/discount/workflow model hierarchy; detailed_lines on InvoiceStandardLine is declared non-optional (no ?) which conflicts with the Go converter returning nil when the slice is empty (pre-existing issue from earlier review round).
api/spec/packages/aip/src/customers/charges/charges.tsp Model and field renames (BillingFlatFeeCharge → BillingChargeFlatFee, managed_by → lifecycle_controller, ResourceManagedBy → LifecycleController); these are wire-level breaking changes for any consumer already using the v3 charges endpoint.
api/spec/packages/aip/src/shared/enums.tsp Replaces ResourceManagedBy (manual/system/subscription) with LifecycleController (system/manual); intentional consolidation but removes the subscription discrimination capability.
api/v3/handlers/billingprofiles/convert.go Adds ToAPIBillingSupplier helper and fixes address-emission logic to include all non-empty address fields (not just Country); both changes look correct.
api/v3/server/server.go Cleanly adds billingInvoicesHandler field and initialization; the merge conflict markers previously present on this file have been resolved.
e2e/billinginvoices_v3_test.go Comprehensive end-to-end test covering the happy-path GET and 404 for unknown IDs; the gathering-invoice 404 assertion passes for the right outcome but potentially for the wrong reason since the advance step moves the gathering invoice's lines too.
api/spec/packages/aip-client-javascript/src/funcs/invoices.ts Generated SDK function for getInvoice; uses .json() on a non-void 200 response which is correct per the SDK conventions.

Sequence Diagram

%%{init: {'theme': 'neutral'}}%%
sequenceDiagram
    participant Client
    participant Server as v3 Server (routes.go)
    participant Handler as billinginvoices.handler
    participant Service as billing.Service
    participant Conv as ToAPIBillingInvoice
    participant ErrEnc as errorEncoder

    Client->>Server: "GET /api/v3/openmeter/billing/invoices/{invoiceId}"
    Server->>Handler: GetBillingInvoice().With(invoiceId)
    Handler->>Handler: resolveNamespace(ctx)
    Handler->>Service: GetInvoiceById(InvoiceID + InvoiceExpandAll)
    alt invoice found
        Service-->>Handler: billing.Invoice (union)
        Handler->>Conv: ToAPIBillingInvoice(inv)
        alt "type == InvoiceTypeStandard"
            Conv->>Conv: toAPIStandardInvoice()
            Conv->>Conv: toAPIWorkflow()
            Conv->>Conv: mapLines() → mapStandardLine() → mapRateCard() + mapDetailedLines()
            Conv-->>Handler: BillingInvoice (union)
            Handler-->>Client: 200 OK JSON
        else unsupported type (e.g. gathering)
            Conv-->>Handler: billing.NotFoundError
            Handler->>ErrEnc: HandleErrorIfTypeMatches[NotFoundError]
            ErrEnc-->>Client: 404 Not Found
        end
    else invoice not found
        Service-->>Handler: billing.NotFoundError
        Handler->>ErrEnc: errorEncoder chain
        ErrEnc-->>Client: 404 Not Found
    end
Loading
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
sequenceDiagram
    participant Client
    participant Server as v3 Server (routes.go)
    participant Handler as billinginvoices.handler
    participant Service as billing.Service
    participant Conv as ToAPIBillingInvoice
    participant ErrEnc as errorEncoder

    Client->>Server: "GET /api/v3/openmeter/billing/invoices/{invoiceId}"
    Server->>Handler: GetBillingInvoice().With(invoiceId)
    Handler->>Handler: resolveNamespace(ctx)
    Handler->>Service: GetInvoiceById(InvoiceID + InvoiceExpandAll)
    alt invoice found
        Service-->>Handler: billing.Invoice (union)
        Handler->>Conv: ToAPIBillingInvoice(inv)
        alt "type == InvoiceTypeStandard"
            Conv->>Conv: toAPIStandardInvoice()
            Conv->>Conv: toAPIWorkflow()
            Conv->>Conv: mapLines() → mapStandardLine() → mapRateCard() + mapDetailedLines()
            Conv-->>Handler: BillingInvoice (union)
            Handler-->>Client: 200 OK JSON
        else unsupported type (e.g. gathering)
            Conv-->>Handler: billing.NotFoundError
            Handler->>ErrEnc: HandleErrorIfTypeMatches[NotFoundError]
            ErrEnc-->>Client: 404 Not Found
        end
    else invoice not found
        Service-->>Handler: billing.NotFoundError
        Handler->>ErrEnc: errorEncoder chain
        ErrEnc-->>Client: 404 Not Found
    end
Loading

Reviews (14): Last reviewed commit: "refactor: replace InvoiceWorkflowAppRefe..." | Re-trigger Greptile

Comment thread api/v3/handlers/billinginvoices/convert.go
Comment thread api/spec/packages/aip/src/invoices/invoice.tsp
Comment thread api/v3/handlers/billinginvoices/convert.go
Comment thread api/v3/handlers/billinginvoices/convert.go Outdated
Comment thread api/v3/handlers/billinginvoices/convert.go
Comment thread api/spec/packages/aip/src/invoices/invoice.tsp Outdated
Comment thread api/spec/packages/aip/src/invoices/invoice.tsp Outdated
Comment thread api/spec/packages/aip/src/invoices/invoice.tsp Outdated
Comment thread api/spec/packages/aip/src/invoices/invoice.tsp Outdated
Comment thread api/spec/packages/aip/src/invoices/invoice.tsp
Comment thread api/spec/packages/aip/src/invoices/invoice.tsp Outdated
Comment thread api/spec/packages/aip/src/invoices/invoice.tsp Outdated
Comment thread api/spec/packages/aip/src/invoices/invoice.tsp Outdated
Comment thread api/spec/packages/aip/src/invoices/invoice.tsp Outdated
Comment thread api/spec/packages/aip/src/invoices/invoice.tsp Outdated
Comment thread api/spec/packages/aip/src/invoices/invoice.tsp Outdated
Comment thread api/spec/packages/aip/src/invoices/invoice.tsp Outdated
Comment thread api/spec/packages/aip/src/invoices/invoice.tsp Outdated
Comment thread api/spec/packages/aip/src/invoices/invoice.tsp Outdated

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 9

🧹 Nitpick comments (3)
api/spec/packages/aip/src/invoices/invoice.tsp (1)

2-2: 📐 Maintainability & Code Quality | 🔵 Trivial

Drop the ../invoices/index.tsp import from invoice.tsp.

invoice.tsp already declares namespace Invoices, and this import forms a circular dependency with index.tsp without adding anything here.

Suggested cleanup
-import "../invoices/index.tsp";
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@api/spec/packages/aip/src/invoices/invoice.tsp` at line 2, Remove the
unnecessary `../invoices/index.tsp` import from `invoice.tsp`; the file already
defines `namespace Invoices`, so the import adds no value and creates a circular
dependency with `index.tsp`. Update `invoice.tsp` to keep only its own namespace
and related declarations, and ensure nothing else in this file relies on symbols
from `index.tsp`.
e2e/billinginvoices_v3_test.go (1)

106-129: 📐 Maintainability & Code Quality | 🔵 Trivial | 🏗️ Heavy lift

Broaden the assertions around the new invoice contract.

Nice start, but this happy path only checks a few top-level fields and the 404 case only checks problem != nil. That leaves most of the new surface in this PR—like invoice line fields (quantity, unit_price), workflow payload, and the billing-specific problem body—effectively untested. Adding a representative line assertion plus a couple of concrete 404 problem-field checks would make this endpoint much harder to regress silently.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@e2e/billinginvoices_v3_test.go` around lines 106 - 129, Broaden the coverage
in the v3 invoice GET tests by asserting the new contract fields exposed through
GetBillingInvoice and AsBillingStandardInvoice. In the happy-path subtest, add
checks for at least one invoice line’s quantity and unit_price, and verify the
workflow payload is present and well-formed on the decoded standard invoice. In
the 404 subtest, go beyond problem != nil by asserting concrete billing problem
body fields on the returned problem object so the error shape is validated too.

Source: Path instructions

api/spec/packages/aip-client-javascript/src/models/operations/invoices.ts (1)

4-6: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Prefer an interface for the request shape.

This is a plain object contract, so interface keeps it aligned with the repo’s TS conventions.

Suggested fix
-export type GetInvoiceRequest = {
+export interface GetInvoiceRequest {
   invoiceId: string
 }

As per coding guidelines, "Prefer interface for defining object shapes in TypeScript".

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@api/spec/packages/aip-client-javascript/src/models/operations/invoices.ts`
around lines 4 - 6, The request contract in GetInvoiceRequest is currently
declared as a type alias, but this plain object shape should use an interface to
match the repo’s TypeScript conventions. Update the GetInvoiceRequest definition
in invoices.ts from a type alias to an interface, keeping the same invoiceId
field so the request shape remains unchanged.

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@api/spec/packages/aip-client-javascript/src/models/schemas.ts`:
- Around line 5188-5193: The invoice schema only includes standardInvoice in the
discriminated union, so credit_note payloads cannot be matched and the
credit-note branch is unreachable. Update the invoice
z.discriminatedUnion('type', ...) to include creditNoteInvoice alongside
standardInvoice, and ensure the credit note schema has its own unique
z.literal('credit_note') discriminator rather than sharing the standard type.
Keep the change localized to the invoice and creditNoteInvoice schema
definitions so the union resolves correctly by type.
- Around line 4758-4796: The invoice schema still excludes credit notes, so
update the union wiring around invoiceType and invoice to include credit-note
support. Add creditNoteInvoice to the invoice discriminated union alongside
standardInvoice, and extend invoiceType so it accepts the credit note variant as
well; use the existing invoiceType, invoice, standardInvoice, and
creditNoteInvoice symbols to locate the relevant schema definitions.

In `@api/spec/packages/aip-client-javascript/src/models/types.ts`:
- Around line 3311-3312: The `detailed_lines` field documentation in
`InvoiceLine` and `InvoiceLineInput` still mentions the removed `status` field,
so update both comments to describe the actual condition under which the array
is present. Use the `detailed_lines` property declarations in `types.ts` to
locate the stale wording and replace it with accurate SDK docs that no longer
reference `status`.
- Around line 2864-2865: The credit-note invoice variant is using the same
discriminator as StandardInvoice, which makes union narrowing and parsing
ambiguous. Update the credit-note branch in types.ts so the Invoice union has
its own unique discriminator value on the type field, and make sure any related
parsing/matching logic that keys off Invoice.type recognizes this new
credit-note discriminator alongside StandardInvoice.

In `@api/spec/packages/aip/src/invoices/invoice.tsp`:
- Around line 717-720: The documentation for the detailed sub-lines field refers
to a non-existent status property, so update the comment to describe the actual
presence rule instead. In the invoice schema around the detailed_lines
documentation, remove the outdated “Present when status is detailed or split”
wording and replace it with wording that matches the real model/implementation,
using the relevant field name as the source of truth.
- Around line 314-318: The doc comments on the invoice snapshot models are stale
and still refer to BillingParty inheritance even though the shapes are now
standalone. Update the summaries for the affected invoice snapshot types in
invoice.tsp, especially the snapshot-related declarations around
InvoiceCustomerSnapshot and the other cited snapshot model, so they describe the
actual standalone customer/billing snapshot data and any usage attribution
fields without mentioning extends or BillingParty.
- Around line 217-224: The invoice model’s `lines` field is underspecified for
the single-resource GET contract because it is marked optional even though
`BillingInvoice` always returns it. Update the `BillingInvoice`/`lines`
declaration in the invoice spec so the GET response reflects the actual
implementation by making `lines` required there, and only model omission
separately for any future list-shaped contract rather than weakening the current
`@visibility(Lifecycle.Read)` shape.

In `@api/v3/handlers/billinginvoices/convert.go`:
- Around line 25-37: The union dispatcher in convertInvoice only handles
billing.InvoiceTypeStandard, so it must be extended to map the other invoice
variants supported by the v3 contract. Update the switch on inv.Type() to add
the credit note case (and any other union members returned by GetInvoiceById),
convert each variant to its API shape, and populate the corresponding out union
setter instead of falling through to the unsupported invoice type error. Use the
existing helpers in this file, such as toAPIStandardInvoice and
out.FromBillingStandardInvoice, as the pattern for the new variant mappings.

In `@api/v3/handlers/billingprofiles/convert.go`:
- Around line 166-168: The address mapping in ToAPIBillingProfile is currently
guarded only by supplier.Address.Country, which causes valid supplier addresses
with line1, city, or postal_code but no country to be dropped. Update the
condition around the ToAPIAddress call so it maps any non-empty
supplier.Address, using the existing ToAPIAddress helper and the
supplier.Address fields as the source of truth, rather than requiring Country to
be set.

---

Nitpick comments:
In `@api/spec/packages/aip-client-javascript/src/models/operations/invoices.ts`:
- Around line 4-6: The request contract in GetInvoiceRequest is currently
declared as a type alias, but this plain object shape should use an interface to
match the repo’s TypeScript conventions. Update the GetInvoiceRequest definition
in invoices.ts from a type alias to an interface, keeping the same invoiceId
field so the request shape remains unchanged.

In `@api/spec/packages/aip/src/invoices/invoice.tsp`:
- Line 2: Remove the unnecessary `../invoices/index.tsp` import from
`invoice.tsp`; the file already defines `namespace Invoices`, so the import adds
no value and creates a circular dependency with `index.tsp`. Update
`invoice.tsp` to keep only its own namespace and related declarations, and
ensure nothing else in this file relies on symbols from `index.tsp`.

In `@e2e/billinginvoices_v3_test.go`:
- Around line 106-129: Broaden the coverage in the v3 invoice GET tests by
asserting the new contract fields exposed through GetBillingInvoice and
AsBillingStandardInvoice. In the happy-path subtest, add checks for at least one
invoice line’s quantity and unit_price, and verify the workflow payload is
present and well-formed on the decoded standard invoice. In the 404 subtest, go
beyond problem != nil by asserting concrete billing problem body fields on the
returned problem object so the error shape is validated too.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 0359abbf-2727-498a-a4b9-e1609084e610

📥 Commits

Reviewing files that changed from the base of the PR and between a8cd4ec and 2f8a011.

⛔ Files ignored due to path filters (1)
  • api/v3/openapi.yaml is excluded by !**/openapi.yaml
📒 Files selected for processing (25)
  • api/spec/packages/aip-client-javascript/README.md
  • api/spec/packages/aip-client-javascript/src/funcs/index.ts
  • api/spec/packages/aip-client-javascript/src/funcs/invoices.ts
  • api/spec/packages/aip-client-javascript/src/index.ts
  • api/spec/packages/aip-client-javascript/src/models/operations/invoices.ts
  • api/spec/packages/aip-client-javascript/src/models/schemas.ts
  • api/spec/packages/aip-client-javascript/src/models/types.ts
  • api/spec/packages/aip-client-javascript/src/sdk/invoices.ts
  • api/spec/packages/aip-client-javascript/src/sdk/sdk.ts
  • api/spec/packages/aip/src/invoices/index.tsp
  • api/spec/packages/aip/src/invoices/invoice.tsp
  • api/spec/packages/aip/src/invoices/operations.tsp
  • api/spec/packages/aip/src/konnect.tsp
  • api/spec/packages/aip/src/openmeter.tsp
  • api/v3/api.gen.go
  • api/v3/handlers/billinginvoices/convert.go
  • api/v3/handlers/billinginvoices/error_encoder.go
  • api/v3/handlers/billinginvoices/get.go
  • api/v3/handlers/billinginvoices/handler.go
  • api/v3/handlers/billingprofiles/convert.go
  • api/v3/handlers/customers/charges/convert.go
  • api/v3/server/routes.go
  • api/v3/server/server.go
  • e2e/billinginvoices_v3_test.go
  • e2e/v3helpers_test.go

Comment thread api/spec/packages/aip-client-javascript/src/models/schemas.ts Outdated
Comment thread api/spec/packages/aip-client-javascript/src/models/schemas.ts Outdated
Comment thread api/spec/packages/aip-client-javascript/src/models/types.ts Outdated
Comment thread api/spec/packages/aip-client-javascript/src/models/types.ts Outdated
Comment thread api/spec/packages/aip/src/invoices/invoice.tsp Outdated
Comment thread api/spec/packages/aip/src/invoices/invoice.tsp
Comment thread api/spec/packages/aip/src/invoices/invoice.tsp
Comment thread api/v3/handlers/billinginvoices/convert.go Outdated
Comment thread api/v3/handlers/billingprofiles/convert.go Outdated
Comment thread api/v3/handlers/billinginvoices/convert.go Outdated
@borosr
borosr force-pushed the feat/v3-invoice-api-get branch from b99fc39 to 4cb8268 Compare June 24, 2026 09:50
Comment thread api/v3/server/server.go Outdated

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@api/v3/server/server.go`:
- Around line 325-330: Resolve the merge conflict in server.go by removing the
conflict markers and keeping both handlers wired correctly. In the server setup
near plansHandler and billingInvoicesHandler, preserve the required
planshandler.New contract by passing config.UnitConfig.Enabled along with
resolveNamespace, config.PlanService, and
httptransport.WithErrorHandler(config.ErrorHandler), and also keep the
billingInvoicesHandler.New constructor with its namespace, billing service, and
error handler. Ensure the block compiles cleanly with both constructors intact.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: fe3ab63d-021d-4fec-b537-38031e2b8ddd

📥 Commits

Reviewing files that changed from the base of the PR and between b99fc39 and 4cb8268.

⛔ Files ignored due to path filters (1)
  • api/v3/openapi.yaml is excluded by !**/openapi.yaml
📒 Files selected for processing (25)
  • api/spec/packages/aip-client-javascript/README.md
  • api/spec/packages/aip-client-javascript/src/funcs/index.ts
  • api/spec/packages/aip-client-javascript/src/funcs/invoices.ts
  • api/spec/packages/aip-client-javascript/src/index.ts
  • api/spec/packages/aip-client-javascript/src/models/operations/invoices.ts
  • api/spec/packages/aip-client-javascript/src/models/schemas.ts
  • api/spec/packages/aip-client-javascript/src/models/types.ts
  • api/spec/packages/aip-client-javascript/src/sdk/invoices.ts
  • api/spec/packages/aip-client-javascript/src/sdk/sdk.ts
  • api/spec/packages/aip/src/invoices/index.tsp
  • api/spec/packages/aip/src/invoices/invoice.tsp
  • api/spec/packages/aip/src/invoices/operations.tsp
  • api/spec/packages/aip/src/konnect.tsp
  • api/spec/packages/aip/src/openmeter.tsp
  • api/v3/api.gen.go
  • api/v3/handlers/billinginvoices/convert.go
  • api/v3/handlers/billinginvoices/error_encoder.go
  • api/v3/handlers/billinginvoices/get.go
  • api/v3/handlers/billinginvoices/handler.go
  • api/v3/handlers/billingprofiles/convert.go
  • api/v3/handlers/customers/charges/convert.go
  • api/v3/server/routes.go
  • api/v3/server/server.go
  • e2e/billinginvoices_v3_test.go
  • e2e/v3helpers_test.go
✅ Files skipped from review due to trivial changes (2)
  • api/spec/packages/aip-client-javascript/src/funcs/index.ts
  • api/spec/packages/aip-client-javascript/src/models/operations/invoices.ts
🚧 Files skipped from review as they are similar to previous changes (21)
  • api/v3/handlers/billinginvoices/error_encoder.go
  • api/v3/handlers/billinginvoices/handler.go
  • api/spec/packages/aip-client-javascript/src/sdk/invoices.ts
  • api/spec/packages/aip/src/openmeter.tsp
  • api/v3/server/routes.go
  • api/v3/handlers/billingprofiles/convert.go
  • api/v3/handlers/billinginvoices/get.go
  • api/spec/packages/aip/src/invoices/operations.tsp
  • api/spec/packages/aip-client-javascript/src/funcs/invoices.ts
  • e2e/billinginvoices_v3_test.go
  • api/spec/packages/aip-client-javascript/README.md
  • api/spec/packages/aip/src/invoices/index.tsp
  • api/spec/packages/aip/src/konnect.tsp
  • api/v3/handlers/customers/charges/convert.go
  • e2e/v3helpers_test.go
  • api/spec/packages/aip-client-javascript/src/sdk/sdk.ts
  • api/v3/handlers/billinginvoices/convert.go
  • api/spec/packages/aip/src/invoices/invoice.tsp
  • api/spec/packages/aip-client-javascript/src/index.ts
  • api/spec/packages/aip-client-javascript/src/models/types.ts
  • api/spec/packages/aip-client-javascript/src/models/schemas.ts

Comment thread api/v3/server/server.go Outdated
Comment thread api/v3/handlers/billinginvoices/convert.go
Comment thread api/spec/packages/aip/src/invoices/invoice.tsp Outdated
Comment thread api/spec/packages/aip/src/invoices/invoice.tsp Outdated

@turip turip left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice

Comment thread api/v3/handlers/billinginvoices/convert.go Outdated
Comment thread api/v3/handlers/billinginvoices/convert.go Outdated
Comment thread api/v3/handlers/billinginvoices/convert.go
Comment thread api/v3/handlers/billinginvoices/convert.go
Comment thread api/v3/handlers/billinginvoices/convert.go Outdated
Comment thread api/v3/handlers/billinginvoices/convert.go
@tothandras tothandras changed the title Invoice V3 API Get endpoint feat(api): add invoice V3 GET endpoint Jun 25, 2026
Comment thread api/spec/packages/aip/src/invoices/invoice.tsp
Comment thread e2e/billinginvoices_v3_test.go
@borosr
borosr force-pushed the feat/v3-invoice-api-get branch from 3188916 to ae35a6e Compare June 26, 2026 08:21
@borosr
borosr force-pushed the feat/v3-invoice-api-get branch from ae35a6e to 39736aa Compare June 26, 2026 08:25
Comment thread api/v3/handlers/billinginvoices/convert.go
@borosr
borosr force-pushed the feat/v3-invoice-api-get branch from 69a1621 to 4cc29fc Compare June 26, 2026 10:02
@tothandras
tothandras merged commit ac21fbf into main Jun 26, 2026
28 of 29 checks passed
@tothandras
tothandras deleted the feat/v3-invoice-api-get branch June 26, 2026 10:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release-note/feature Release note: Exciting New Features

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants